
(defpackage :game
  (:use :cl :weblocks
        :f-underscore :anaphora)
  (:import-from :hunchentoot #:header-in
		#:set-cookie #:set-cookie* #:cookie-in
		#:user-agent #:referer)
  (:documentation
   "A web application based on Weblocks."))

(in-package :game)

(export '(start-game stop-game))

;; A macro that generates a class or this webapp

(defwebapp game
    :prefix "/game"
    :description "preferrence: A new application"
    :init-user-session 'game::init-user-session
    :autostart t                   ;; have to start the app manually
    :ignore-default-dependencies t ;; accept the defaults
    :dependencies (list
                    (make-instance 'script-dependency :url "/js/jQuery.js")
                    (make-instance 'script-dependency :url "/js/jquery.ba-bbq.js")
                    (make-instance 'script-dependency :url "/js/weblocks-jquery.js")
                    (make-instance 'script-dependency :url "/js/dialog-jquery.js")
                    (make-instance 'script-dependency :url "/js/jquery-seq.js")
                    (make-instance 'script-dependency :url "/js/game.js")
                    (make-instance 'stylesheet-dependency :url "/css/game.css"))
                    
    :debug t
    )

;; Top level start & stop scripts

(defun start-game (&rest args)
  "Starts the application by calling 'start-weblocks' with appropriate
arguments."
  (apply #'start-weblocks args)
  (start-webapp 'game))

(defun stop-game ()
  "Stops the application by calling 'stop-weblocks'."
  (stop-webapp 'game)
  (stop-weblocks))

